/*
   Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
   Original sources are available at www.latestbit.com

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

package org.latestbit.smartobjects.network;

import org.latestbit.smartobjects.RequestContext;
import org.latestbit.smartobjects.coders.IDataTypesCoder;
import org.latestbit.smartobjects.io.ResizableByteBuffer;

/**
 * Base interface for all network commands
 * @author abdulla-a
 *
 */
public interface INetworkCommand {
	
	/**
	 * Gets protocol version byte
	 * @return protocol version
	 */
	public byte getProtocolVersion();
	
	/**
	 * Gets command identifier byte
	 * @return command identifier byte
	 */
	public byte getCommandId();
	
	/**
	 * Gets command destination information
	 * @return destination information
	 */
	public String getDestination();
	
	/**
	 * Gets destination instance information
	 * @return destination instance information
	 */
	public String getInstanceId();
	
	/**
	 * Gets message identifier
	 * @return message identifier
	 */
	public int getMessageId();
	
	/**
	 * Gets request context information 
	 * @return request context
	 */
	public RequestContext getRequestContext();
	
	/**
	 * Gets access to raw buffer
	 * @return byte buffer
	 */
	public ResizableByteBuffer getBuffer();
	
	/**
	 * Sets new raw buffer instance
	 * @param buffer byte buffer
	 */
	public void setBuffer ( ResizableByteBuffer buffer );
	
	/**
	 * Checks request command type
	 * @return true - if this command is request, else - false
	 */
	public boolean isRequest();
	
	/**
	 * Checks response command type
	 * @return true - if this command is response, else - false
	 */	
	public boolean isResponse();
	
	/**
	 * Checks this command already serialized to byte buffer
	 * @return true if serialized to byte buffer
	 */
	public boolean isSerialized();
	
	/**
	 * Checks this command deserialized from byte buffer
	 * @return true if deserialized from byte buffer
	 */	
	public boolean isDeserialized();
	
	/**
	 * Gets data types coder instance
	 * @return data types coder instance
	 */
	public IDataTypesCoder getDataTypesCoder();
}
